package com.yan.ems.mapper;

import com.yan.ems.pojo.entity.User;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository
public class UserMapper {
	private static final Map<String, User> userMap = new HashMap<>();
	public User getUserByUsername(String username) {
		return userMap.get(username);
	}

	public void addUser(User user) {
		userMap.put(user.getUsername(), user);
	}

	public void updateUser(User user) {
		userMap.put(user.getUsername(), user);
	}

	public void deleteUser(String username) {
		userMap.remove(username);
	}

	public int getCount() {
		return userMap.size();
	}
}
